package JVM;

/**
 * @author:谢君臣
 * @Date:2021/8/28-14:59
 * @version:1.0
 * @function:
 */
public class TestS {
    public static void main(String[] args) {
        String s1 = "a";
        String s2 = "b";
        String s3 = "a"+"b";
        String s4 = s1+s2;
        String s5 = "ab";
        String s6 = s4.intern();

        System.out.println((s3 == s4)+":false");
        System.out.println((s3 == s5)+":true");
        System.out.println((s3 == s6)+":true");

        String x2 = new String("c")+new String("d");
        String x1 = "cd";
        String s = x2.intern();
        System.out.println(s);
        System.out.println((x1 == x2)+":false");
        String x4 = new String("e")+new String("f");
        x4.intern();
        String x3 = "ef";
        System.out.println((x4 == x3)+":true");
    }
    public void test1(){
        String x2 = new String("c")+new String("d");
        String x1 = "cd";
        x2.intern();
        System.out.println((x1 == x2)+":false");
    }
    public void test2(){
        String x2 = new String("c")+new String("d");
        x2.intern();
        String x1 = "cd";
        System.out.println((x1 == x2)+":false");
    }
    public void test3(){
        String x2 = new String("d");
        String s = x2.intern();
        System.out.println(s == x2);
    }
}
